package kiwi.assist.dev.guieditor.command {
	import flash.utils.setTimeout;

	import kiwi.assist.dev.guieditor.event.GUIEditorEvent;

	import org.robotlegs.mvcs.Command;

	import flash.desktop.NativeApplication;
	import flash.events.InvokeEvent;

	/**
	 * @author zhangming.luo
	 */
	public class InitCompleteCommand extends Command {
		override public function execute() : void {
			super.execute();
			// TODO:等待加载完毕
			setTimeout(function() : void {
				// 自动打开
				NativeApplication.nativeApplication.addEventListener(InvokeEvent.INVOKE, onInvoke);
			}, 2000);
		}

		private function onInvoke(event : InvokeEvent) : void {
			if (!event.arguments.length) {
				return;
			}
			dispatch(new GUIEditorEvent(GUIEditorEvent.LOAD_UIXML, event.arguments[0]));
		}
	}
}
